package cn.geminis.crypto.csp.soft.rsa;

import cn.geminis.crypto.csp.AbstractDigest;
import cn.geminis.crypto.csp.AbstractMac;
import cn.geminis.crypto.csp.AbstractSigner;
import org.bouncycastle.asn1.oiw.OIWObjectIdentifiers;
import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;

/**
 * @author puddi
 */
public class RsaSha1CspFactory extends RsaCspFactory {

    public RsaSha1CspFactory(String keyPath, String pin, String moduleLength) {
        super(keyPath, pin, moduleLength);
    }

    @Override
    public String getDigestAlgOid() {
        return OIWObjectIdentifiers.idSHA1.toString();
    }

    @Override
    public String getDigestAlgName() {
        return "SHA1";
    }

    @Override
    public AbstractDigest createDigest() {
        return new Sha1Digest();
    }

    @Override
    public String getSignerAlgOid() {
        return PKCSObjectIdentifiers.sha1WithRSAEncryption.toString();
    }

    @Override
    public String getSignerAlgName() {
        return "Sha1WithRSA";
    }

    @Override
    public AbstractSigner createSigner() {
        return new Sha1WithRsaSigner(publicKey, privateKey);
    }

    @Override
    public AbstractMac createMac() {
        return new Sha1HMac();
    }

}
